<%@ page language="java" import="java.util.*,java.text.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>课表List</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<script type="text/javascript" src="<%=path%>/js/jQuery/jquery-1.6.min.js"></script>
	<script type="text/javascript">
	 	$(document).ready(function(){
	 		var nextvalue;
	 		var par;
	 		var flag = "";
	 		var newwin = window.showModalDialog("classCondition.jsp", "", "dialogTop:300px;dialogWidth:600px;dialogHeight:150px;location=no; dialogLeft:300px;modal=yes");
	 		if(newwin==""||newwin==null){//系院ID+专业ID+班级ID("all")+专业名+班级名+课表名
	 			$("#data").html("<br><br><br><marquee direction='left' amount=10><h1>请输入排课的班级</h1></marquee>");
	 			return false;
	 		}else{
	 			par = newwin.split(",");
	 			$("#professionalName").html(par[3]);
	 			$("#classesName").html(par[4]);
	 			$("#scheduleName").html(par[5]);
	 			$.ajax({
						url: "/schedule/querySchedule",
						data: "flag="+par[2]+","+par[5],
						type: "POST",
						success:function(data){
								$(data.root).each(function(index,schedule){
									var course = schedule.teachersRCourse.course;
									var teachers = schedule.teachersRCourse.teachers;
									var classroom = schedule.classroom;
									var classes = schedule.classes;
									$("#"+schedule.scheduleWeek+"-"+schedule.scheduleSchoolTime).html("<input type='hidden' value='"+schedule.teachersRCourse.id+"-"+classroom.id+"-"+schedule.scheduleWeek+"-"+schedule.scheduleSchoolTime+"' /><div align='center' id='courses'>"+course.course_name+"("+teachers.teachers_name+") "+course.course_totaltime+"<br>"+classroom.teachingbuilding.teachingbuilding_name+"-"+classroom.name+"</div>");
								});        
						}
					});  
	 		}
	 		var td = $('#data TD').not("#data TD:first-child");
	 		td.bind({ contextmenu: function(e) {//鼠标右击
                if (e.which == 3)
                    alert("hello");
                    return false;
            }
            });
			td.click(function() {
				nextvalue = window.showModalDialog("choiceCourse1.jsp", newwin, "dialogTop:200px;dialogWidth:600px;dialogHeight:300px; dialogLeft:200px;scroll=yes");
				//teachersRCourseID+classroomId+classroomName+courseName(teacherName)
				if(nextvalue==null||""==nextvalue){
					return false;
				}else{
					var courses = nextvalue.split("-");//信息论 48 （1-12）<br>庄曰华 T3-B202
					$(this).html("<input type='hidden' value='"+courses[0]+"-"+courses[1]+"-"+$(this).attr("id")+"' /><div align='center' id='courses'>"+courses[4]+"<br>"+courses[2]+"-"+courses[3]+"</div>");
				}
			});
			$("input[name=reset]").click(function(){//重置
					td.html("");
				}); 
			$("#submit2").click(function(){//提交
			       //标题+班级Id
				   flag = $("#scheduleName").text()+"-"+par[2]+"@";
				   $("input[type=hidden]").each(function(index,schedule){
				   		flag += $(this).attr("value")+",";
				   });	
				   alert(flag);
		           $.ajax({
						url: "/schedule/addSchedule",
						data: "flag="+flag,
						type: "POST",
						success:function(data){
							window.reload();
						}
					});  
			});
		});
	</script>

<body leftmargin=20 topmargin=20  bottommargin="1" bgcolor="#DFE8F6">
<form name="form1" id="form1" method="post" action="/schedule/addSchedule" style="margin-bottom:2px">
  <div align="center" id="buttondiv">
  <TABLE id="data" width=100% height=96% border="0" bordercolor="#FF0000" cellspacing="1"  >
    <TR bgcolor="FFFFFF">
      <TH height='15' colspan="6" id=""><label id="scheduleName"></label></TH>
      </TR>
      <TR bgcolor="FFFFFF">
      <TH height='15' colspan="6" id=""><span style="float:left" >&nbsp;&nbsp;&nbsp;专业：<label id="professionalName"></label></span><span style="float:right">班级：<label id="classesName"></label>&nbsp;&nbsp;&nbsp;</span></TH>
      </TR>
    <TR bgcolor="FFFFFF" height="10%">
      <TH width="10%" height='40' id="">节数/
      星期</TH>
    <TH width="18%">星期一</TH>
    <TH width="18%">星期二</TH>
    <TH width="18%">星期三</TH>
    <TH width="18%">星期四</TH>
    <TH width="18%">星期五</TH>
    </TR>
    <TR id="星期一" bgcolor="FFFFFF" height="15%">
      <TD><div align="center">一二节</div></TD>
      <TD id="星期一-一二节" align="center"></TD>
      <TD id="星期二-一二节" align="center">信息论 48 （1-12）<br>庄曰华 T3-B202</TD>
      <TD id="星期三-一二节"></TD>
      <TD id="星期四-一二节"></TD>
      <TD id="星期五-一二节"></TD>
    </TR>
    <TR id="星期二" bgcolor="FFFFFF" height="15%">
      <TD><div align="center">三四节</div></TD>
      <TD id="星期一-三四节"></TD>
      <TD id="星期二-三四节"></TD>
    <TD id="星期三-三四节"></TD>
    <TD id="星期四-三四节"></TD>
    <TD id="星期五-三四节"></TD>
    </TR>
    <TR id="星期三" bgcolor="FFFFFF" height="15%">
      <TD><div align="center">五六节</div></TD>
      <TD id="星期一-五六节"></TD>
      <TD id="星期二-五六节"></TD>
    <TD id="星期三-五六节"></TD>
    <TD id="星期四-五六节"></TD>
    <TD id="星期五-五六节"></TD>
    </TR>
    <TR id="星期四" bgcolor="FFFFFF" height="15%">
      <TD><div align="center">七节</div></TD>
      <TD id="星期一-七节"></TD>
      <TD id="星期二-七节"></TD>
    <TD id="星期三-七节"></TD>
    <TD id="星期四-七节"></TD>
    <TD id="星期王-七节"></TD>
    </TR>
    <TR id="星期五" bgcolor="FFFFFF" height="15%">
      <TD><div align="center">八九节</div></TD>
      <TD id="星期一-八九节"></TD>
      <TD id="星期二-八九节"></TD>
    <TD id="星期三-八九节"></TD>
    <TD id="星期四-八九节"></TD>
    <TD id="星期五-八九节"></TD>
    </TR>
    <TR bgcolor="FFFFFF" height="10%">
    <% DateFormat df = new SimpleDateFormat("yyyy年MM月dd日"); %>
      <TD colspan="6"><span style="float:left">&nbsp;&nbsp;&nbsp;备注：1.第8-9节（冬)19:00-20:40  (夏)19:30-21:10</span><span style="float:right"><%=df.format(new Date())%>&nbsp;&nbsp;&nbsp;</span></TD>
     </TR>
    <TR bgcolor="FFFFFF" height="10%">
      <TD width=100% colspan="6" align="center">
	  	<input type="reset" name="reset" style="background:#7C97E4" value="重置">  
        <input type="button" style="background:#7C97E4" name="Submit2" id="submit2" value="提交" > 
        <input type="button" style="background:#7C97E4" name="Submit3"  value="打印" >
       </TD>
    </TR>
  </TABLE>
  </div>
</form>
<div id="foot" style="background:white;text-align: center;"> </div>
</BODY>
</html>